<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	//thiet lap layout
	public function _initScriptLayout(){
		
			$options = array(
					'layout'=>'index',//khong co slider
					'layoutPath'=>APPLICATION_PATH.'/layouts/default'
			);
			Zend_Layout::startMvc($options);
				
		
	}
	public function _initBackUrl(){
		
	}
	
	public function _initDefaultConstant(){
	// ĐƯỜNG DẪN TỚI THƯ MỤC PUBLIC
		defined('FACEBOOK_URL')
			|| define('FACEBOOK_URL', 'http://tdhh.zz.mu/');
	}
	public function _initScriptPublicResource(){
		/**
			Thiet lap duong dan co so
			very important
		 */
		$view = new Zend_View();
		$view->headTitle()->setSeparator(" | ");
		//$baseUrl = $view->baseUrl().'/public';
		$baseUrl = $view->baseUrl();
		define('PUBLIC_RESOURCE', $baseUrl);
	}
	
	public function _initScriptCard(){
		$card = new Zend_Session_Namespace('card');
	}
	
	// site da ngon ngu
	public function _initScriptLanguage(){
	       $this->bootstrap('frontController');
		  $front = $this->getResource('frontController');
            //$front = Zend_Controller_Front::getInstance();
            $front->registerPlugin(new Cms_Language_Lang());
            //$view = new Zend_View();
            
//		$front = Zend_Controller_Front::getInstance();
//		$languageSession = new Zend_Session_Namespace('languageSession');
//		if(!isset($languageSession->languageSystem)){
//			$languageSession->languageSystem="vi";
//		}
//		$front->setParam('languageSystem', $languageSession->languageSystem);
//		$languageFile = APPLICATION_PATH."/languages/".$languageSession->languageSystem.".php";
//		
//		if(file_exists($languageFile)){
//			$translate = new Zend_Translate('array',$languageFile,$languageSession->languageSystem);
//			Zend_Registry::set('Zend_Translate', $translate);
//		}else{
//			trigger_error('language file not exitst');
//		}
//		
//		return $translate;
		return $front;		
	}
	
	public function _initRoute() {		
		/**
			Rewrite url 
		 */
		$front = Zend_Controller_Front::getInstance ();		
		$config = new Zend_Config_Ini ( APPLICATION_PATH . "/configs/routers.ini", "thietlap" );
		$router = new Zend_Controller_Router_Rewrite ();
		$router->addConfig ( $config, 'routes' );
		$front->setRouter ( $router );
		return $front;
	}
}

